<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>查看报告</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../../static/layui/dist/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../../static/layui/dist/layuiadmin/style/admin.css" media="all">

  <script src="../js/jquery.min.js"></script>
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>



<div class="layui-bg-gray" style="padding: 10px;">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-body" >
            <div class="demoTable">
            搜索ID：
            <div class="layui-inline">
              <input class="layui-input" name="id" id="demoReload" autocomplete="off">
            </div>
            <button class="layui-btn" data-type="reload">搜索</button>
          </div>
        </div>
        <div class="layui-card-body" id='edit-body'>
            <table class="layui-hide" id="LAY_table_user" lay-filter="demo"></table>
        </div>
          
      </div>
    </div>


<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->

<script type="text/html" id="barDemo">
  <a class="layui-btn  layui-btn-xs" lay-event="detail">查看</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>


<script src="../../../static/layui/dist/layuiadmin/layui/layui.all.js"></script>
<script>
layui.use(['table', 'layedit', 'laydate','form'], function(){
  var table = layui.table
  ,$ = layui.jquery
  ,form=layui.form;
  

  

  //方法级渲染
  table.render({
    elem: '#LAY_table_user'
    ,url: 'portpage'
    ,cols:[[
        {field:'uid', title:'员工编号', width:120, unresize: true, sort: true,align:'center'},
        {field:'department',title:'部门',width:100,sort:true,align:'center'},
        {field:'user_name',title:'员工姓名',width:150,sort:true,align:'center',},
        {field:'title',title:'工作报告',width:300,sort:true,align:'center'},
        {field:'created_time',title:'报告时间',width:180,sort:true,align:'center'},
        {field:'updated_time',title:'修改时间',sort:true,align:"content",align:'center'},
        {field: 'right', title: '操作', align:'center' ,width: 115, toolbar: "#barDemo",}
        ]]
    ,id: 'testReload'
    ,page: true
    ,limit:20

  });
  
  

  //监听表内点击事件
  table.on('tool(demo)', function(obj){
    var data = obj.data;

    //判断表内点击按钮
    if(obj.event === 'detail'){
      layui.use('layer', function(){
        
        var $ = layui.$
        $.ajax({
          type : 'get',
          url: 'getreport?content='+data.title,
          success: function(get_data){
            
            if (get_data.code == 200){
            var title = get_data.title
            var report = get_data.report
            
            layer.open({
            type: 2,
            content: '/workreport/see',
            area:['100%','100%'],
            success: function(layero, index){
              var body = layer.getChildFrame('body', index);
              var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();

              body.find('input').val(title)
              body.find('textarea').val(report)
          }
        })
      }
  }
});
});
      // layer.msg('ID：'+ data.id + ' 的查看操作');
    } else if(obj.event === 'del'){
      layer.confirm('真的删除行么', {icon: 3, title:'提示'},function(index){
        obj.del();
        layer.close(index);
        var parmas = "title="+data.title;
          $.ajax({
          url:'/workreport/del',
          type:'post',
          data:parmas,
          success:function(res){
            alert(res);
              }
        })
        
      });
    } 
  });

  var $ = layui.$, active = {
    reload: function(){
      var demoReload = $('#demoReload');

      //执行重载
      table.reload('testReload', {
        page: {
          curr: 1 //重新从第 1 页开始
        }
        ,where: {
          search: $('#demoReload').val()
            
          
        }
      });
    }
  };
  var $ = layui.jquery
  //获取当前窗口高度
  var document_body = $(document).height()
  //更改编辑器body总高度为窗口高度的百分比
  $('#edit-body').height(document_body*0.87)

  //监听点击按钮
  $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');

    active[type] ? active[type].call(this) : '';
  });
});
</script>


</body>
</html>